#!/usr/bin/perl
use Socket;
use IO::Handle;
use constant DEFAULT_ADDR => '127.0.0.1';
use constant PORT         => 15123;
use constant IPPROTO_TCP => 6;

my $address =  DEFAULT_ADDR;
my $packed_addr = inet_aton($address);
my $destination = sockaddr_in(PORT,$packed_addr);
my $a1=$ARGV[0];
my $a2=$ARGV[1];
my $a3=$ARGV[2];
my $a4=$ARGV[3];
my $ain;
if(length($a4)>=1)
{
	$ain="$a1 $a2 $a3 $a4\n";
}
else
{
	$ain="$a1 $a2 $a3\n";
}


socket(SOCK,PF_INET,SOCK_STREAM,IPPROTO_TCP) or die "Socket err:$!";
connect(SOCK,$destination) or die "Connect err:$!";
SOCK->autoflush(1);

	        unless (defined($child_pid=fork())) {die "Cound not create fork!n"};
        if($child_pid)
        {
			print SOCK "$ain";
                while(<SOCK>)
                {
                        print $_;
                }
        }else{
        }
#close SOCK or die "close:$!";
